<? $this->title ='Products'; ?>
{{wrap with="front_page_layout.phtml" into="content"}}

<p/>
<? $alphabet = AlphabetHelper :: getAlphabet(); ?>

<a href="{{route_url params='controller:product'}}">Display all</a>

{{list using="$alphabet"}}
    {{list:item}}
    <? if(isset($item['current'])) { ?>
    <b>{$item.letter|uppercase}</b>
    <? } else { ?>
    <a href='product?letter={$item.letter}'>{$item.letter|uppercase}</a>
    <? } ?>
    {{/list:item}}
{{/list}}

<p/><b>Search the products:</b>
{{form method="GET" id='search_form' name='search_form' action='product'}}

  <label for='product'>Product title:</label>
  {{input type="text" name="product" id="product" size='10'/}}

  <label for='price_greater'>Price greater:</label>
  {{input type="text" name="price_greater" id="price_greater" type="text" size='4'/}}

  <label for='price_less'>Price less:</label>
  {{input type="text" name="price_less" id="price_less" type="text" size='4'/}}

  <input type='submit' name='search' value="Search!" class='button'/><br/>
  <input type='hidden' name='action' value='search'/>
{{/form}}

<? $products = Product :: findForFront(); ?>

{{paginate iterator='$products' pager="pager"/}}

{{include file='pager.phtml'/}}

{{list using="$products"}}
<table cellpadding="0" cellspacing="0" class='list'>
  <thead>
  </thead>
  {{list:item}}
  <tr>
   <td>
      <dl>
        <dt>
          <b>{$item.title}</b><br />
          Price:<b>${$item.price|number:2, '.', ' '}</b><br/>
          <a href="{{route_url params='controller:cart,action:add,id:{$item.id}'}}">Add to cart</a><br/>
         </dt>
         <dd>
            <img src='{$item.image_path}' class='img'/>
            {$item.description|nl2br}
         </dd>
      </dl>
    </td>
  </tr>
  {{/list:item}}
</table>
{{/list}}

{{/wrap}}
